home *** CD-ROM | disk | FTP | other *** search
/ 3D Game Programming All in One / 3D Game Programming All in One Disc.iso / 3D2E / RESOURCES / CH3 / turnshape.cs < prev   
Text File  |  2006-06-28  |  1KB  |  27 lines

  1. // ========================================================================
  2. //  turnshape.cs
  3. //
  4. //  This module contains a function for turning a specified shape.
  5. // ========================================================================
  6.  
  7. function TurnShape(%shape, %angle)
  8. // ----------------------------------------------------
  9. //     turns the %shape by %angle amount.
  10. // ----------------------------------------------------
  11. {
  12.    echo ("TurnShape: shape id: ", %shape);
  13.    echo ("TurnShape: angle: ", %angle);
  14.    %xfrm = %shape.getTransform();
  15.    %lx = getword(%xfrm,0); // first, get the current transform values
  16.    %ly = getword(%xfrm,1);
  17.    %lz = getword(%xfrm,2);
  18.    %rx = getword(%xfrm,3);
  19.    %ry = getword(%xfrm,4);
  20.    %rz = getword(%xfrm,5);
  21.    %angle += 1.0;          // increment the angle (ie. rotate it a bit)
  22.    %rd = %angle;           // Set the rotation angle
  23.    %shape.setTransform(%lx SPC %ly SPC %lz SPC %rx SPC %ry SPC %rz SPC %rd);
  24.    echo ("TurnShape: done.");
  25. }
  26.  
  27.